package org.javaboy.properties_demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.env.EnvironmentPostProcessor;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.stereotype.Component;
import org.springframework.web.context.support.StandardServletEnvironment;

import java.util.HashMap;
import java.util.Map;

public class MyEnvPostProcessor implements EnvironmentPostProcessor {
    @Override
    public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
        String property = environment.getProperty("project.name");
        StandardServletEnvironment standardServletEnvironment = (StandardServletEnvironment) environment;
        Map<String, Object> defaultProps = new HashMap<>();
        defaultProps.put("project.name", "decrypt:" + property);
        application.setDefaultProperties(defaultProps);
    }
}
